package Thread;

public class ThreadDemo8 {
    public static void main(String[] args) {
        Thread thread = new Thread(()->{
                //这个线程运行时间大概是1秒
                try {
                    Thread.sleep(1000);
                    System.out.println("当前线程是否存活:"+Thread.currentThread().isAlive());
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
        });
        System.out.println("start之前："+thread.isAlive());
        thread.start();
        System.out.println("start之后："+thread.isAlive());
        //2s之后这个进程已经结束了
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println("进程结束之后:"+thread.isAlive());
    }
}
